var dateType = '1',  //日期类型
    dateStart = '', //开始日期
    dateEnd = '';   //结束日期
//用户选择
function selectSH(id) {
	var te = $("#SH").attr("btnType");
	if(te == "隐藏") {
		$("#SH").attr("btnType", "显示");
		$("#selectBox").fadeIn(600, function() {
			$("#selectBox").css("display", "block")
		})
	}
	if(te == "显示") {
		$("#SH").attr("btnType", "隐藏");
		$("#selectBox").fadeOut(600, function() {
			$("#selectBox").css("display", "none")
		})
	}
}
//设置session参数
function setSessionfunc(typeid,zid){
	//设置当前用户的session值
    //typeid 系统分类id (比如对应前端八大类), zid 当前用户的站点id
	var url="/bigscrenn/setUserSession?typeid="+typeid+"&zid="+zid;
    $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
              console.log(data,'参数');         
	     }
    		
    });	
};
//进入页面先获取其实时间
//var sDate = $(".show input#test1").val();
//var eDate = $(".show input#test6").val();
var sDate;
var eDate;
var userID='',zID=''; //定义全局的用户id站点id
//energyVUEFunc();
setTimeout(energyVUEFunc,456);
function energyVUEFunc(){
	sDate = $(".show input#test1").val();
	eDate = $(".show input#test6").val();
	var vm = new Vue({
		el:"#app",
		data:{
			userid : "",   //用户id
			unitID : "",   //单位id
			userType : "", //用户类型
			kehu : [],     //左边列表
			zid : "",      //站点
			zName:'',       //站点名称
		    danweiID:'',    //单位id
		    danweiName:'',   //单位名称
			
		},
		mounted:function(){
			this.getSession();//session方法
		},
		methods:{
			//session
			getSession:function(){
				var vs = this;
				var userid,unitID,userType;
				var url="/bigscrenn/getUserSession";
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
				    	 console.log("session数据：",data);
				    	 //js解析json串
			     	     var obj = JSON.parse(data);
			             if (obj.session.length>0){
			                   /*alert(obj.session[0].UserID);//用户id
			                   alert(obj.session[0].Name);//用户名称
			                   alert(obj.session[0].UnitID);//用户单位id
			                   alert(obj.session[0].UserAuthority);//用户权限 2 所有单位 3 本单位
			                   alert(obj.session[0].typeid);//系统分类id (比如对应前端八大类)
			                   alert(obj.session[0].zid);//当前用户的站点id*/
			            	   vs.userid = obj.session[0].UserID;
			 	  			   vs.unitID = obj.session[0].UnitID;
			 	  			   vs.userType = obj.session[0].UserAuthority;
			 	  			   //vs.zid = obj.session[0].zid;
			 	  			   //alert("站点id="+vs.zid);
			 	  			   
			 	  			   userID = obj.session[0].UserID;//给全局userid赋值
			 	  			   
			 	  			   //alert("userID="+userID+"and zID="+zID) ;
			 	  			   
			 	  			   vs.danweiID = (obj.session[0].cid1).split(",")[0];  //单位id方法
			 	  			   vs.danweiName = (obj.session[0].cid1).split(",")[1];//上页选中来的单位名称
			 	  			   
			 	  			   //vs.zid = obj.session[0].zid;
			 	  			   vs.zid = (obj.session[0].zid).split(",")[0];  //站点id
			 	  			   vs.zName = (obj.session[0].zid).split(",")[1];//上页选中来的站点名称
			 	  			   zID = vs.zid;//给全局unitid赋值
			 	  			   //alert("能耗分析 vs.danweiID="+vs.danweiID + " vs.danweiName= "+vs.danweiName +"vs.zid = "+vs.zid +"vs.zName = "+vs.zName);
			 	  			   $('#topTitle').text(vs.zName);
			 	  			   
			 	  			   zhandianid = zID;
			 	  			   onlineFunc();
			 	  			   
			 	  			   console.log("站点id="+vs.zid);
			 	  			   //setSessionfunc('',vs.zid+','+vs.zName,'',(vs.danweiID+','+vs.danweiName));     // session存站点（第二个参）
			 	  			   
			            	 }
			                 //alert("userid="+vs.userid+"and unitID="+vs.unitID+"and userType="+vs.userType) ;
				             if(vs.danweiID==undefined||vs.danweiID==''){
			                	 vs.danweiID=vs.unitID;
			                 }	
			                 vs.getUnitIData(vs.userid,vs.danweiID);
			                
			                //具体用户进来的操作
			                if(vs.userType==3){
			                	console.log("我的身份是具体用户");
			                	$(".backHome-box >a").css("display","none");// “返回首页”隐藏
			                }
			                defaultFunc(userID,vs.zid); //进入默认数据方法
				     }
			     });
			},
			//站点
			getUnitIData:function(sy_userid,sy_uniId){
				var unitData = this;
				// userid用户id,unitid单位id,unitid为空时表示调用多个单位的站点信息
			    var url="/bigscrenn/getSiteList?userid="+sy_userid+"&unitid="+sy_uniId;
			     console.log("站点地址url="+url);
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
                       // alert("站点列表="+data);
                       // js解析json串
                       var obj = JSON.parse(data);
                        // alert("记录数="+obj.total);//记录数
                       unitData.kehu = obj.rows;// 分类后的站点（用户）
                       unitData.$nextTick(function() {
                    	   var arrr = $(".zhanDian");
                    	   var thisCid="";
                    	   for (var n=0;n<arrr.length;n++){
                    		   arrr[n].index = n;
                    		   arrr[n].onclick = function(){
                    			   // alert($(this).text());
                    			   thisCid = $(this).attr("cid");
                    			   console.log("thisCid="+thisCid);
                    			   setSessionfunc('',thisCid+','+$(this).text(),'',(unitData.danweiID+','+unitData.danweiName));     // session存站点（第二个参）
	                        	   window.location.href = "./specificUser.html";// 返回具体页面
                    		   }
                    		   
                    	   }
                       });
				     }
			     });
			},
		},
	})
}


// 得到指定站点能耗走势统计(非首页使用)
//getZouShiFunc();
function getZouShiFunc(url){
    // 参数userid用户id,unitid站点id,type统计类别 1 按日统计2 按月统计 3 按年度统计 4
	// 按多年度统计,sdate统计日期1,edate统计日期2
    // var url="/bigscrenn/getEnergyZS?userid=0100000000000004&unitid=000000000001&type=1&sdate=2018-12-16&edate=";
     //alert("能耗走势统计地址="+url)
     var fs = "";
     var fsname = "";
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
               console.log("指定站点能耗走势统计="+data);
               // js解析json串
               var obj = JSON.parse(data);
               var subs = new Array();
               var zlen = 0;
               var legendArr = [];
               for (var i=0;i<obj.frows.length;i++){
                     // alert(obj.frows[i].ITEM);//项目
                     // alert(obj.frows[i].DATA);//数据
                     
                     if (i==0)
                     {fs=obj.frows[i].ITEM;}
                     else
                     {fs=fs+ ","+obj.frows[i].ITEM;}
                     
                      
                     var obj1 = JSON.parse(obj.frows[i].DATA);
                     legendArr = obj1.rows[0].NAME;//取第一组数据用于legend
                     for (var j=0;j<obj1.rows.length;j++){
                    	  //alert(obj1.rows[j].NAME);//名称
                         // alert(obj1.rows[j].VALUE);//数据
                         
                         if (i==0)
                         { 
                        	 zlen = obj1.rows.length;
                        	 subs[j]=obj1.rows[j].VALUE;
                             if (j==0)
                             {
                            	 fsname = obj1.rows[j].NAME;
                             }else
                             {
                            	 fsname = fsname + "," + obj1.rows[j].NAME;
                             }
                         }
                         else
                         {
                        	 subs[j]=subs[j]+ ","+obj1.rows[j].VALUE;
                         }
                         
                         
                     }
               }
               
               var xZhou = [],parentArr = [],legendArr=[];
               var child1=[],child2=[],child3=[],childValueArr=[];
               // 得到组中文名
               //alert("得到组中文名:"+fsname);
               // 得到大组数据
               //alert("得到大组数据:"+typeof(fs));
               //alert(JSON.stringify(subs));
               for (var i=0;i<zlen;i++){
            	   //alert(i+"组数据:"+subs[i]);
            	   /*child1 = subs[0].split(',');   //数据字符串->数组
            	   child2 = subs[1].split(',');
            	   child3 = subs[2].split(',');*/
            	   
            	   childValueArr.push(subs[i].split(','));
            	   //alert(i+"childValueArr="+JSON.stringify(childValueArr));
               }
               //alert(i+"childValueArr="+(childValueArr).length);
               //alert("fs=="+fs);  
               xZhou = fs.split(',');  //横轴 字符串->数组
               
               //对能耗走势趋势填充操作
               var outArr = [];
               legendArr = fsname.split(',');
               //alert(legendArr.length);
               
               //outArr.push(child1,child2,child3,child4);
               outArr = childValueArr;
               nenghaoZouShiFunc(outArr,xZhou,legendArr);//调用图表
	     }
     });
}

//点击查寻操作
function func(){
	if($(".show >input").length==1){
		dateStart = $(".show input").val();
		dateEnd = '';
	}
	if($(".show >input").length==2){
		dateStart = $(".show input").eq(0).val();
		dateEnd = $(".show input").eq(1).val();
	}
	
	dateType = $('.xz').find('input').attr('datetype');
	
	//查询的能耗占比
    var ZNurl="/bigscrenn/getEnergyZB?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
    console.log("查询的能耗占比地址url=:"+ZNurl);
    getBintuFunc(ZNurl);
    
    // 点击查询趋势走向
    var CX_trendUrl = "/bigscrenn/getEnergyZS?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
    console.log("点击查询趋势走向=CX_trendUrl:"+CX_trendUrl);
    getZouShiFunc(CX_trendUrl);
    
    // 查询能耗明细饼图
    var MXurl = "/bigscrenn/getEnergyZBMX?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
    console.log("查询后能耗明细饼图地址=:"+MXurl);
    somePieFunc(MXurl);
}
function defaultFunc(userID,zID) {
	if($(".show >input").length==1){
		dateStart = $(".show input").val();
		dateEnd = '';
	}
	if($(".show >input").length==2){
		dateStart = $(".show input").eq(0).val();
		dateEnd = $(".show input").eq(1).val();
	}
	// 进入页面默认显示
	
	//走势
	 //走势图默认显示操作（注：参数unitid是站点id,type=1是日选项）
	var zoushi_url = "/bigscrenn/getEnergyZS?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
    getZouShiFunc(zoushi_url);
	
	// 占比
	var ZBdefaulturl="/bigscrenn/getEnergyZB?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
	getBintuFunc(ZBdefaulturl);
	// m明细
	var defaultMXurl="/bigscrenn/getEnergyZBMX?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
	somePieFunc(defaultMXurl);
    
	var nhfx_dateType="",itemid='',nx_sDate='',nx_eDate='';
	$(".am-radio-inline").removeClass('xz');
	$(".am-radio-inline").eq(0).addClass('xz');
	var nenghaoRiqi = $(".am-radio-inline");
	nenghaoRiqi.click(function() {
		var index = nenghaoRiqi.index(this);
		$(".am-radio-inline").removeClass('xz');
		$(".am-radio-inline").eq(index).addClass('xz');
		
		//监测点击事件单选事件
		if($(".show >input").length==1){
			dateStart = $(".show input").val();
			dateEnd = '';
		}
		if($(".show >input").length==2){
			dateStart = $(".show input").eq(0).val();
			dateEnd = $(".show input").eq(1).val();
		}
		//日期类型
		dateType = $(this).find('input').attr('dateType');
		//alert("dateStart = "+dateStart +" dateEnd = "+dateEnd +" dateType = "+dateType);
		localStorage.setItem("nhfx_dateType",nhfx_dateType);
		// 参数userid用户id,unitid站点id,itemid统计项目id,type统计类别 1 按日统计2 按月统计 3 按年度统计 4
		// 按多年度统计,sdate统计日期1,edate统计日期2
		// url="/bigscrenn/getEnergyZBMX?userid=0100000000000004&unitid=000000000001&type="+nhfx_dateType+"&sdate="+sDate+"&edate=";
	    // alert("点击后的能耗url=:"+url);
		
	    var ZNurl="/bigscrenn/getEnergyZB?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
	    //alert("点击后的能耗占比ZBurl=:"+ZNurl);
	    getBintuFunc(ZNurl);
	    
	    // 能耗明细饼图
	    var MXurl = "/bigscrenn/getEnergyZBMX?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
	    //alert("点击后能耗明细饼图地址=:"+MXurl);
	    somePieFunc(MXurl);
	    
	    
	    // 点击查询趋势走向
	    var djRp_trendUrl = "/bigscrenn/getEnergyZS?userid="+userID+"&unitid="+zID+"&type="+dateType+"&sdate="+dateStart+"&edate="+dateEnd;
	    //alert("点击查询趋势走向djRp_trendUrl=:"+djRp_trendUrl);
	    getZouShiFunc(djRp_trendUrl);
	})
	
}


function getBintuFunc(url){
	// 得到指定站点能耗占比分析统计(非首页使用)
    // 参数userid用户id,unitid站点id,itemid统计项目id,type统计类别 1 按日统计2 按月统计 3 按年度统计 4
	// 按多年度统计,sdate统计日期1,edate统计日期2
    // var url="/bigscrenn/getEnergyZB?userid=0100000000000004&unitid=000000000001&type=1&sdate=2018-12-15&edate=";
    //alert("指定站点能耗占比地址 = "+url);
	var nenghaoZBArr = [];
    $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
           console.log("指定站点能耗占比饼图=:"+data);
           // js解析json串
    	   if(data && data!='' && data!=null && data!=undefined){
    		   var obj = JSON.parse(data);
               for (var i=0;i<obj.rows.length;i++)
               {
                     // alert(obj.rows[i].NAME);//名称
                     // alert(obj.rows[i].VALUE);//数据
                   nenghaoZBArr.push({"value":obj.rows[i].VALUE,"name":obj.rows[i].NAME+obj.rows[i].VALUE})
               }
    	   }else{
    		   nenghaoZBArr.push({"value":0,"name":''})
    	   }
    	   nengHaoZhanBiFunc(nenghaoZBArr)
	     }
     });
}
// =========明细饼图ajaxS==========
// 各个设备(饼图数据)ajax
// 得到指定站点能耗占比明细分析统计(非首页使用)
// somePieFunc();
function somePieFunc(url){
	//console.log("站点能耗占比明细进来的地址="+url);
	var somePieArrS=[], somePieArr = [],somePieArr1=[],somePieArr2=[],somePieArr3=[],somePieArr4=[],legendArr=[],datas=[];
    // 参数userid用户id,unitid站点id,type统计类别 1 按日统计2 按月统计 3 按年度统计 4
	// 按多年度统计,sdate统计日期1,edate统计日期2
	 // var
	// url="/bigscrenn/getEnergyZBMX?userid=0100000000000004&unitid=000000000001&type=1&sdate=2018-12-15&edate=";
	 $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
		    	 //alert("各个设备(饼图明细数据) = " +data);
		          console.log(data,"各个设备(饼图明细数据)=");
		          var mxTitle = []; //饼图明细标题
		         if(data&&data!='' && data != null && data != undefined){
		        	// js解析json串
			         var obj = JSON.parse(data);
			         //alert("obj = "+JSON.stringify(obj));
			         for (var i=0;i<obj.frows.length;i++){
				            //alert(obj.frows[i].ITEM);//项目
				           // alert(obj.frows[i].DATA);//数据
			        	   
			        	  mxTitle.push(obj.frows[i].ITEM);
			        	 
			        	   var arr = [];
				           var obj1 = JSON.parse(obj.frows[i].DATA);
				           for (var j=0;j<obj1.rows.length;j++){
				          	 // alert(obj1.rows[j].NAME);//名称
			                 // alert(obj1.rows[j].VALUE);//数据
				             
							 //arr.push(obj1.rows[j]);
				        	   arr.push({'name':obj1.rows[j].NAME+obj1.rows[j].VALUE,'value':obj1.rows[j].VALUE})
				           }
				           datas.push(arr)
			         }
			         console.log(datas,"datas")
			         
			         //==========明细个数操作
			         //alert("datas = "+JSON.stringify(datas));
			         if(datas&&datas.length>0){
			        	 buildMyChart(datas);   //调用动态增加图表方法
			        	 mingxiFunc(datas,mxTitle);
			        	 //alert("datas.length = "+datas.length);
			         }else{
			        	 somePieArr4.push({"value":0,"name":''});
				         mingxiFunc(somePieArr4,mxTitle[4]);
			         }
			         //打印明细标题
			         console.log(JSON.stringify(mxTitle))
		         }	
		     }
	  });
	 // alert("somePieArr=="+JSON.stringify(somePieArr));
     
}

//=========明细饼图ajaxS==========
function mingxiFunc(oneArr,mxTitle) {
	
	for(var i = 0; i < oneArr.length; i++) {
		for (var j = 0; j < oneArr[i].length; j++) {
			//alert(JSON.stringify(oneArr[i]));
			var data = nameTo_(oneArr[i]);
			var title = oneArr[i][j].name;
			//alert("data = "+JSON.stringify(data));
		}
	//alert("title = "+title);
	console.log("明细饼图 oneArr = "+oneArr);
	var mychart = document.getElementById('nenghao-pie-child' + (i+1));
	var healthChart = echarts.init(mychart);
	//var healthChart = echarts.init(document.getElementById("alarmTJ5"));//"alarmTJ1"
	var health_option = {
		title: {
			//text: "一路电度",
			text:mxTitle[i],
			top: '20%',
			x: 'center',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				fontSize: 20
			}
		},

		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b}: {c} ({d}%)"
		},
		legend: {
			show:true,
			orient: 'horizontal',
			x: 'center',
			bottom: '7%',
			itemGap: 10,
// data: ['办公室照明电度', '波峰焊照明电度', '回流焊照明电度', '仓库照明电度'],
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 14
			}
		},
		series: [{
			name:mxTitle[i],
			//name: '二路电度',
			type: 'pie',
			radius: ['35%', '50%'],
			center: ['50%', '60%'],
			avoidLabelOverlap: false,
			label: {
				normal: {
					show: false,
					position: 'center'
				},
				emphasis: {
					show: true,
					textStyle: {
						fontSize: '15',
						fontWeight: 'bold'
					}
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data:data,
			/*
			 * data: [{ "name": "办公室照明电度", "value": 134 }, { "name": "波峰焊照明电度",
			 * "value": 114 }, { "name": "回流焊照明电度", "value": 94 }, { "name":
			 * "仓库照明电度", "value": 214 }],
			 */
			itemStyle:{
				normal: {
					color: function(params) {
						// 自定义饼图颜色
						var colorList = [
							//'#20B9CF', '#DE67F4', '#De17F2', '#16d5bF'
							'#20b9cf', '#DE67F4', '#FF8C00', '#FF0000', '#FE8463',
						];
						return colorList[params.dataIndex]
					}
				}

			},
			
		}]
	};
	healthChart.setOption(health_option);
	$(document).ready(function() {
		healthChart.resize();
	});
	window.addEventListener("resize", function() {
		healthChart.resize();
	})
	}
}

// 能耗占比 开始
function nengHaoZhanBiFunc(nenghaoZBArr) {
	if(nenghaoZBArr==''){
		nenghaoZBArr = [0];
	}
	var equipmentChart = echarts.init(document.getElementById("nenghaozhanbi-total"));
	var equipmentOption = {
		title: {
			text: '能耗占比',
			top: '20%',
			x: 'center',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 18
			}
		},
		legend: {
			show:true,
			icon: 'rect',
			//data: ,
			align: 'right',
			x: 'center',
			bottom: '7%',
			textStyle: {
				// 文字颜色
				color: '#fff',
				// 字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				// 字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 |
				// 400...
				fontWeight: '100',
				// 字体系列
				fontFamily: 'sans-serif',
				// 字体大小
				　　　　fontSize: 14
			},
			itemWidth: 30,
			itemHeight: 10,
			itemGap: 15
		},
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c} ({d}%)"
		},
		series: [{
			name: '能耗占比',
			type: 'pie',
			radius: ['0%', '55%'],
			center: ['50%', '60%'],
			data:nenghaoZBArr,
			label: {
				normal: {
					show:false,
					//formatter: '{b}:{c}: ({d}%)',
					formatter: '{c} ({d}%)',////饼图边的脚数据
					textStyle: {
						fontWeight: 'normal',
						fontSize: 12
					}
				}
			},
			/*
			 * data: [{ value: 310, name: '照明', textStyle: { fontSize: 20 } }, {
			 * value: 234, name: 'SMT(设备)' }, { value: 135, name: '波峰焊(设备)' }, {
			 * value: 548, name: '其他' } ],
			 */
			itemStyle: {
				emphasis: {
					shadowBlur: 10,
					shadowOffsetX: 0,
					shadowColor: 'rgba(0, 0, 0, 0.5)'
				},
				 normal:{
                     color:function(params) {
                     //自定义颜色
                     var colorList = [           
                             '#20b9cf', '#DE67F4', '#FF8C00', '#FF0000', '#FE8463',
                         ];
                         return colorList[params.dataIndex]
                      }
                 }
			}
		}]
	};
	equipmentChart.setOption(equipmentOption);
	$(document).ready(function() {　　
		equipmentChart.resize();
	})
	window.addEventListener("resize", function() {　　
		equipmentChart.resize();
	});
}
// 能耗占比 结束

// 能耗走势 开始
function nenghaoZouShiFunc(arrs,shijian,legendArr) {
	var myChart3 = echarts.init(document.getElementById('nenghaoZousshi'));
	option3 = {
	    color:['#4472C5','#ED7C30','#80FF80'],
		backgroundColor: "rgb(0,0,0,.2)",
		title:{
			text:"能耗走势",
			x:"2%",
			y:"3%",
			textStyle:{
				color:"#fff"
			}
		},
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				lineStyle: {
					color: '#57617B'
				}
			}
		},
		legend: {
			show:false,
			icon: 'rect',
			data: legendArr,
			align: 'right',
			right: '2%',
			top: '12%',
			textStyle: {
				color: "#fff"
			},
			itemWidth: 30,
			itemHeight: 10,
			itemGap: 15
		},
		grid: {
			left: '1%',
			right: '2%',
			top: '20%',
			bottom: '5%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			boundaryGap: false,
			axisLine: {
				lineStyle: {
					color: '#fff'
				}
			},
// data: ['13:00', '13:05', '13:10', '13:15', '13:20', '13:25', '13:30',
// '13:35', '13:40', '13:45', '13:50', '13:55']
			data: shijian
		}, {
			axisLine: {
				show: false, // 上横轴
				lineStyle: {
					color: 'red',
				}
			},

		}],
		yAxis: [{
			axisLabel: {
				show: true,
				formatter: '{value}'
			},
			splitLine: {
				lineStyle: {
					color: 'rgba(255,255,255,.1)'
				}
			},
			axisLine: {
				lineStyle: {
					color: '#fff'
				}
			},
		}],
		
		series:function(){
			//颜色数组(注：定义数据变量置前面)
			var colorArr = [
				[{
					offset: 0.99,
					color: 'rgba(222,103,244, 0.2)'
				}, {
					offset: 0.9,
					color: 'rgba(222,103,244, 0.3)'
				}, {
					offset: 0.7,
					color: 'rgba(222,103,244, 0.5)'
				}, {
					offset: 0.5,
					color: 'rgba(222,103,244, 0.7)'
				}, {
					offset: 0.3,
					color: 'rgba(222,103,244, 0.8)'
				}, {
					offset: 0.1,
					color: 'rgba(222,103,244, 0.99)'
				}],[{
					offset: 0.99,
					color: 'rgba(79,148,255, 0.2)'
				}, {
					offset: 0.9,
					color: 'rgba(79,148,255, 0.4)'
				}, {
					offset: 0.7,
					color: 'rgba(79,148,255, 0.5)'
				}, {
					offset: 0.5,
					color: 'rgba(79,148,255, 0.66)'
				}, {
					offset: 0.3,
					color: 'rgba(79,148,255, 0.86)'
				}, {
					offset: 0.1,
					color: 'rgba(79,148,255, 0.99)'
				}],[{
					offset: 0.99,
					color: 'rgba(15,235,139, 0.2)'
				}, {
					offset: 0.9,
					color: 'rgba(15,235,139, 0.4)'
				}, {
					offset: 0.7,
					color: 'rgba(15,235,139, 0.5)'
				}, {
					offset: 0.5,
					color: 'rgba(15,235,139, 0.66)'
				}, {
					offset: 0.3,
					color: 'rgba(15,235,139, 0.86)'
				}, {
					offset: 0.1,
					color: 'rgba(15,235,139, 0.99)'
				}]
			];
			
			//数据数组
			var dataArr = arrs;
			var serie = [];
			var colorArr =['#20b9cf', '#DE67F4', '#FF8C00', '#FF0000', '#FE8463'];
			for(var i = 0; i < 5; i++) {
				var item = {
					name: legendArr[i],
					type: 'line',
					stack: '总量',
					data: dataArr[i],
					smooth: true,
					symbol: 'circle',
					symbolSize: 5,
					showSymbol: false,
					lineStyle: {
						normal: {
							width: 2
						}
					},
					/*areaStyle: {
						normal: {
							color: new echarts.graphic.LinearGradient(0, 0, 0, 1, colorArr[i], false),
							shadowColor: 'rgba(0, 0, 0, 0.9)',
							shadowBlur: 10
						}
					},*/
					itemStyle: {
						normal: {
							color: colorArr[i],
							borderColor: colorArr[i],
							borderWidth: 12
						}
					}
				}
				serie.push(item);
			};
			
			/* console.log(serie); */
			return serie;
		}()
	};
	
	myChart3.setOption(option3);
	$(document).ready(function() {　　
		myChart3.resize();
	})
	window.addEventListener("resize", function() {　　
		myChart3.resize();
	});
	
}
// 能耗走势 结束

//动态添加图表div
function buildMyChart(dateArr) {
	if($('.zhanbi-pie-inner-echart-child').length>0){
		//alert($('.zhanbi-pie-inner-echart-child').length);
		$('.zhanbi-pie-inner-echart-child').remove();
		//alert($('.zhanbi-pie-inner-echart-child').length);
	}
	var chart1 = "";
	for(var i = 0; i < dateArr.length; i++) {
		chart1 = "<div id='nenghao-pie-child" + (i+1) + "' class='zhanbi-pie-inner-echart zhanbi-pie-inner-echart-child'>";
		$("#nenghao-pie-box").append(chart1);
	}
}

//值班人员
//onlineFunc(zhandianid);
function onlineFunc(){
	//alert("online zhandianid = "+zhandianid);
	// unitid 是站点ID
	// var url="/bigtongji/getRotaList?unitid=000000000001";
	var url="/bigtongji/getRotaList?unitid="+zhandianid;
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
      // alert(data);
      console.log(data);
      var dataObj=eval("("+data+")");// 转换为json对象
      // alert(dataObj);
      // alert(dataObj);
      if(dataObj.rows.length>0){
  		 $("#onlineNotice").html('');
  		 for (var i = 0; i < dataObj.rows.length; i++) {
       		var cid= dataObj.rows[i].cid;
       		var name= dataObj.rows[i].rname;
       		var phone= dataObj.rows[i].phoneCode;
       		//alert(cid);
       		//alert("cid="+cid+"name="+name+"phone="+phone);
      		 $("#onlineNotice").append('<li><span>👨‍⚖️&nbsp;&nbsp;<span id="onlineName1">'+name+'</span>&nbsp;电话：</span><span>'+phone+'</span></li>');
       	  }
  	  }
  	 if(dataObj.rows.length==0){
  		$("#onlineNotice").html(''); 
  	 }
	     }
	 });

}
//值班人员结束

//返回上一级跳转逻辑处理
function bachFunc(){
	var urlsStr = localStorage.getItem("urls");
	var ss = JSON.parse(urlsStr);
	if(ss.sanji != undefined &&  ss.sanji !=''){
    	//alert(ss.sanji);
	    window.location.href = './specificHome.html';
    	return;
    }
    if(ss.erji != undefined && ss.erji !=''){
    	//alert(ss.erji);
	    window.location.href = './intlgMonitor.html';
	    return;
    }if(ss.yiji != undefined &&  ss.yiji !=''){
    	//alert(ss.yiji);
	    window.location.href = './pro_Home.html';
	    return;
    }else{
	   //alert(222)
    }
}

//将对象属性中的大写字母 变为 小写字母
function nameTo_(object) {
    var regObj = new RegExp("([A-Z]+)", "g");
    for (let i in object) {
        if (object.hasOwnProperty(i)) {
            var temp = object[i];
            if (regObj.test(i.toString())) {
                temp = object[i.replace(regObj, function (result) {
                    //return "_" + result.toLowerCase();
                    return result.toLowerCase();
                })] = object[i];
                delete object[i];
            }
            if (typeof temp === 'object' || Object.prototype.toString.call(temp) === '[object Array]') {
                nameTo_(temp);
            }
        }
    }
    return object;
};